#include<stdio.h>
char s[50][80]={"1",
"3",
"13",
"75",
"541",
"4683",
"47293",
"545835",
"7087261",
"102247563",
"1622632573",
"28091567595",
"526858348381",
"10641342970443",
"230283190977853",
"5315654681981355",
"130370767029135901",
"3385534663256845323",
"92801587319328411133",
"2677687796244384203115",
"81124824998504073881821",
"2574844419803190384544203",
"85438451336745709294580413",
"2958279121074145472650648875",
"106697365438475775825583498141",
"4002225759844168492486127539083",
"155897763918621623249276226253693",
"6297562064950066033518373935334635",
"263478385263023690020893329044576861",
"11403568794011880483742464196184901963",
"510008036574269388430841024075918118973",
"23545154085734896649184490637144855476395",
"1120959742203056268267494209293006882589981",
"54984904077825684862426868390301049750104843",
"2776425695289206002630310219593685496163584253",
"144199280951655469628360978109406917583513090155",
"7697316738562185268347644943000493480404209089501",
"421985466101260424678587486718115935844245187819723",
"23743057231588741419119534567705900419786127935577533",
"1370159636942236704917645663312384364386256449136591915",
"81045623051154285047127402304207782853156976521592907421",
"4910812975389574954318759599939388855544783946694910718603",
"304646637632091740261982544696657582136519552428876887346813",
"19338536506753895707368358095646384573117824953447578202397675",
"1255482482235481041484313695469155949742941807533901307975355741",
"83318804148028351409201335290659562069258599933450396080176273483",
"5649570401186486930330812460375430692673276472202704742218853260093",
"391229145645351175841837029639030040330277058716846008212321196523435",
"27656793065414932606012896651489726461435178241015434306518713649426461",
"1995015910118319790635433747742913123711612309013079035980385090523556363"};
main()
{
int n,i,m;
while(scanf("%d",&n)!=EOF)
{
  for(i=0;i<n;i++)
    {scanf("%d",&m);
    printf("%s\n",s[m-1]);
    }
}
return 0;
}